package com.cloud.sky.controller;

import com.cloud.sky.component.TingYuClient;
import com.cloud.sky.entity.common.Result;
import com.cloud.sky.entity.common.ResultCode;
import com.cloud.sky.entity.dto.ResourcePriceDTO;
import com.cloud.sky.entity.vo.ResourcePriceVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 资源定价与结算
 *
 * @author Tyrone
 * @date 2024/8/8 02:18
 */
@RestController
public class PriceController {

    @Autowired
    private TingYuClient tingYuClient;

    @PostMapping("machine/price/list")
    public Result<ResourcePriceVO> resourcePrice(@RequestBody ResourcePriceDTO resourcePriceDTO) {
        ResourcePriceVO resourcePriceVO = tingYuClient.resourcePrice(resourcePriceDTO);
        if (resourcePriceVO != null) {
            return Result.success(resourcePriceVO);
        }
        return Result.failure(ResultCode.failure);
    }

}
